package com.example.service.impl;

import com.example.service.ServiceInterface;
import org.apache.dubbo.config.annotation.Service;

/**
 * @author kangshuai
 */
@Service
public class ServiceInterfaceImpl implements ServiceInterface {

    @Override
    public String methodA() throws Exception {
        System.out.println("this is method A");
        sleep();
        return "success A";
    }

    @Override
    public String methodB() throws Exception {
        System.out.println("this is method B");
        sleep();
        return "success B";
    }

    @Override
    public String methodC() throws Exception {
        System.out.println("this is method C");
        sleep();
        return "success C";
    }

    /**
     * 定义随机休眠时间
     * 范围 0～100 s
     */
    private void sleep() {
        int random = (int) (Math.random() * 100);
        try {
            Thread.sleep(random);
        } catch (Exception e) {

        }
    }
}
